#include <pthread.h>

namespace glf {

typedef pthread_t ThreadId;

inline ThreadId GetCurrentThreadId() {
	return pthread_self();
}

typedef pthread_key_t TlsKey;

inline bool allocTlsKey(TlsKey& key) {
	return pthread_key_create(&key, NULL) == 0;
}

inline bool freeTlsKey(TlsKey key) {
	return pthread_key_delete(key) == 0;
}

inline void* getTlsValue(TlsKey key) {
	return pthread_getspecific(key);
}

inline bool setTlsValue(TlsKey key, void* value) {
	return pthread_setspecific(key, value) == 0;
}

}

